package InformationRetriever.ComparerMethod;

import Jama.Matrix;

public class EuclideanDistanceComparer extends ComparerBase
{    
    public double PerformCompare(int doc1, int doc2)
    {
        Matrix v = this.getV();
        if(v == null) 
            return 0;
        
        double sigmaOfSquaredDifferences = 0;
        for(int i = 0; i < v.getRowDimension(); i++)
            sigmaOfSquaredDifferences += (v.get(i,doc1) - v.get(i,doc2)) * (v.get(i,doc1) - v.get(i,doc2));
        
        return Math.sqrt(sigmaOfSquaredDifferences);        
    }
}
